<?php
session_start();

$loginError = $_GET["loginError"];

//get cookie
$userName = $_COOKIE["user_name"];
$userPassword = $_COOKIE["user_password"];

//get session
$userRole = $_SESSION['user_role'];
if($userRole > 0 && $loginError == ""){
	//根据不同角色forward到不同页面;
	if($userRole == 1){//管理员
		$url =  "../task/taskList.php";
	}else if($userRole == 2){//快递员
		$url =  "../express/expressList.php";
	}else if($userRole == 3){//跟单员
		$url =  "../tracking/trackingList.php";
	}else if($userRole == 4){//订单管理员
		$url =  "../order/orderList.php";
	}else if($userRole == 5){//任务管理员+订单管理员
		$url =  "../task/taskList.php";
	}else if($userRole == 6){//e邮宝 代理
		$url =  "../express/eub.php";
	}else if($userRole == 7){//女装
		$url =  "../clothing/financialList.php";
	}else{
		$url = "../index.php?loginError=1";
	}
	echo "<script language='javascript' type='text/javascript'>";
	echo "window.location.href='$url'";
	echo "</script>";
}


?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--Begin:head-->
<? $pageTitle = "用户登录"; ?>
<?php include("head.php"); ?>
<!--End:head-->


<body>
<?php include("topMenu.php"); ?>


<form name="loginForm" action="../user/userLogin.php" method="post" onSubmit= "return checkForm()">

<center>
<div id="container" >	


<div class="grayTable">	
<table >
<thead>
	<tr>
		<th scope="col" colspan=2 align='left'>用户登录</th>	    
	</tr>
</thead>

	<tr>
		<td align="right">用户名:</td>
		<td align="left"><input type="text" name="user_name" id="user_name" size=30  value="<?php echo $userName; ?>"></td>
	</tr>			
	<tr>
		<td align="right">密&nbsp;码:</td>
		<td align="left"><input type="password" name="user_password" id="user_password" size=30 value="<?php echo $userPassword; ?>"></td>
	</tr>
	<tr>
		<td colspan=2 align="left"><input type="checkbox" name="remember_flag" id="remember_flag" value="1" checked >2周内记住密码</td>
	</tr>
	<tr>
		<td colspan=2 align="right">
		<div class="leftDiv"><font class="colorRed">
		<?php 
		   if($loginError==1){
			   echo "登录失败，请重试。";
		   }else if($loginError==2){
			   echo "权限问题，请联系管理员。";
		   }else if($loginError==3){
			   echo "请先登录.";
		   }
	    ?></font></div>
		<input type="submit" value="登录">
		</td>
	</tr>					
</table>	
</div>



</div><!--end container -->
</center>
</form>
</body>




</html>

<script>
function checkForm(){
	var userName = $("#user_name").val();
	var userPassword = $("#user_password").val();	
	if(userName == ''){
		alert("用户名不能为空.");
		$("#user_name").focus(); 
		return false;
	}
	if(userPassword == ''){
		alert("用户密码不能为空.");
		$("#user_password").focus(); 
		return false;
	}
}

</script>

